<template>
	<view class="my-wrap">
		<tabBar :selectedIndex = 'tabIndex'></tabBar>
		<view class="top-con">
			<view class="title">个人中心</view>
			<view class="contact-con c-flex c-item-center">
				
				<image :src="loginCommon+'delivery_icon.png'"></image>
				<view class="user-info">
					<view class="name" v-if="userName">{{userName}}</view>
					<view class="name" v-else>微信用户</view>
					<view class="phone" >{{maskPhoneNumber(mobile)}}</view>
					
					
				</view>
				
			</view>
		</view>
		<view class="my-content">
			
			<view class="list-con">
				
				<view v-if="type ==='user'" class="list-item c-flex c-flex-row jc-between c-item-center" @tap="gapApply()">
					<view class="c-flex c-item-center">
						<image :src='imgUrl+"apply.png"'></image>
						<text class="label">我的地址</text>
					</view>
					<image src="../../static/images/index/right-icon.png"></image>
				</view>
				<view class="list-item c-flex c-flex-row jc-between c-item-center">
					<view class="c-flex c-item-center">
						<image :src='imgUrl+"contact.png"'></image>
						<text class="label">客服电话</text>
					</view>
					<text class="value">400-101-1677</text>
					<!-- <image src="../../static/images/index/right-icon.png"></image> -->
				</view>
				<!-- <view class="list-item c-flex c-flex-row jc-between c-item-center" @click="onFeedback()">
					<view class="c-flex c-item-center">
						<image :src='imgUrl+"advice.png"'></image>
						<text class="label">意见反馈</text>
					</view>
					<image src="../../static/images/index/right-icon.png"></image>
				</view> -->
				<view class="list-item c-flex c-flex-row jc-between" @tap="onAboutUs()">
					<view class="c-flex c-item-center">
						<image :src='imgUrl+"about.png"'></image>
						<text class="label">关于我们</text>
					</view>
					<image src="../../static/images/index/right-icon.png"></image>
				</view>
				<!-- <view class="list-item c-flex c-flex-row jc-between">
					<text class="label">当前版本</text>
					<text class="value">2.3</text>
				</view>
				<view class="list-item c-flex c-flex-row jc-between" @tap="onUpdatePwd()">
					<text class="label">修改密码</text>
					<image src="../../static/images/index/right-icon.png"></image>
				</view> -->
				<!-- <view class="list-item c-flex c-flex-row jc-between">
					<text class="label">清除缓存</text>
					<text class="value">300KB</text>
				</view> -->
				
				
			</view>
			<view class="loginout-bt" @tap="onLoginout()">退出登录</view>
		</view>
	</view>
</template>

<script>
	import {
		maskPhoneNumber,toast
	} from '@/utils/utils.js'
	export default {
		data() {
			return {
				imgUrl: this.$API.IMG_URL + '/liquefied-mall/my/',
				loginCommon:this.$API.IMG_URL+'/liquefied-mall/common/',
				tabIndex:3,
				userInfo:null,
				maskPhoneNumber:maskPhoneNumber,
				type:null,
				mobile:'',
				userName:''
			}
		},
		onLoad() {
			
			
			this.type = uni.getStorageSync('type');
			if(this.type ==='user'){
				this.tabIndex = 3;
				console.log(JSON.parse(uni.getStorageSync('member')));
				const userInfo = JSON.parse(uni.getStorageSync('member'))
				//this.userInfo = userInfo;
				this.mobile = userInfo.mobile;
				// const loginStatus =  uni.getStorageSync('noLogin');
				// if(!loginStatus){
				// 	uni.navigateTo({
				// 		url:'/pages/login/login'
				// 	})
				// }
			}else if(this.type ==='delivery'){
				this.tabIndex = 1;
				this.$API.liquefieUserInfo({}).then(res=>{
					this.mobile = res.user.mobile;
					this.userName  =res.user.realName;
				});
			}
			
			
			
			
			
		},
		onShow() {
			
			
		},
		methods: {
			gapApply(){
				uni.navigateTo({
					url:'/pages/client/user/user-list'
				})
			},
			
			//退出登录
			onLoginout() {
				wx.setStorageSync('token', '');
				
				wx.setStorageSync('tabIndex', '');
				uni.reLaunch({
					url: '../login/login'
				})
			},
			/**
			 * 修改密码
			 */
			onUpdatePwd(){
				uni.reLaunch({
					url: '../my/update-pwd/update-pwd'
				})
			},
			//意见反馈
			onFeedback(){
				uni.navigateTo({
					url: '../my/feedback/index'
				})
			},
			//关于我们
			onAboutUs() {
				uni.navigateTo({
					url: '../my/about-us/index'
				})
			},
			//联系我们
			onContactUs(){
				uni.makePhoneCall({
						phoneNumber:'4001011677',//电话号码
						success:function(e){
							console.log(e);
						},
						fail:function(e){
							console.log(e);
			
						}
					})
			},
		}
	}
</script>

<style lang="scss" scoped>
	.my-wrap {
		position: relative;
		background-image: linear-gradient(rgba(249, 195, 115, .3) 0%, #F9F9F9 100%);
		height: 100%;
		padding-bottom: 150rpx;

		.top-con {
			width: 100%;
			height: 482rpx;
			// background-image: url(../../static/images/my/my-bg.png);
			// background-size: 100% 482rpx;
			// background-repeat: no-repeat;

			.title {
				
				margin: 0rpx 0 94rpx;
				font-family: PingFangSC, PingFang SC;
				font-weight: 600;
				font-size: 32rpx;
				color: #333333;
				text-align: center;
				position: relative;
				top: 109rpx;   
			}

			.contact-con {
				position: absolute;	width:89%;top: 248rpx;	left: 44rpx;color: #FFFFFF;
				.user-info{
					margin-left: 40rpx;
				}
				.name {
					font-size: 28rpx;margin-top: 8rpx;
					font-family: PingFangSC, PingFang SC;
					font-weight: 600;
					font-size: 32rpx;
					color: #333333;
				}
				.phone{
					margin-top: 11rpx;
					font-family: PingFang-SC, PingFang-SC;
					font-weight: 500;
					font-size: 26rpx;
					color: #9B9B9B;
				}
				image{width: 124rpx;height: 124rpx;border-radius: 50%;float: left;}
			}
		}

		.my-content {
			margin-top: 50rpx;

			.upload-con,
			.sp-con {
				// width: 332rpx;height: 66px;
				width: 35%;
				background: #FFFFFF;
				border-radius: 10px;
				padding: 26rpx 22rpx;

				text:nth-child(1) {
					font-size: 28rpx;
					color: #333333;
					font-weight: 600;
				}

				text:nth-child(2) {
					font-size: 20rpx;
					color: #9B9B9B;
					font-weight: 500;
				}

				image {
					width: 80rpx;
					height: 58rpx;
				}
			}

			.list-con {
				background: #FFFFFF;
				border-radius: 20rpx;
				margin: 22rpx 32rpx;
				padding: 24rpx 44rpx;

				.list-item {
					padding: 32rpx 0;
					view{
						image{
							width: 36rpx;
							height: 40rpx;
						}
						text{
							font-family: PingFang-SC, PingFang-SC;
							font-weight: 500;
							font-size: 30rpx;
							color: #333333;
							margin-left: 44rpx;
						}
					}
					
					.value {
						font-size: 28rpx;
						color: #999999;
					}

					image {
						width: 14px;
						height: 14px;
					}
				}
			}
		}

		.loginout-bt {
			margin: 80rpx 32rpx 0;
			height: 90rpx;
			line-height: 90rpx;
			text-align: center;
			background: #FFFFFF;
			border-radius: 20rpx;
			font-family: PingFang-SC, PingFang-SC;
			font-weight: 500;
			font-size: 30rpx;
			color: #333330;
		}
	}
</style>
